/**
 * Created by python on 19-8-28.
 */


var app = new Vue({
    el: "#history",
    data: {
        // 页面中需要使用到的数据，键值对
        HOST,
        user_id: sessionStorage.user_id || localStorage.user_id,
        token: sessionStorage.token || localStorage.token,
        newses:'',
        questions:'',
        spits:'',

    },
    mounted: function () {
        // 一加载就需要做的，直接是代码
        // alert('hehheh')
        if (this.user_id && this.token) {
            axios.get(this.HOST + 'browse_histories/', {

                headers: {
                    'Authorization': 'JWT ' + this.token
                },
                responseType: 'json',
            })
                .then(response => {
                    console.log(response.data.news);

                    this.spits = response.data.spit;
                    this.newses = response.data.news;
                    this.questions = response.data.question;

                })
        }
    },
    methods: {
        // 需要用到的函数，键值对 ，键是名称，值是匿名函数
         mounted: function () {
        // 一加载就需要做的，直接是代码
        // alert('hehheh')
        if (this.user_id && this.token) {
            axios.post(this.HOST + 'browse_histories/', {

                    history_type: "news",
                    history_id: 1,

            }, {

                headers: {
                    'Authorization': 'JWT ' + this.token
                },
                responseType: 'json',
            })
                .then(response => {
                    // console.log(response.data);
                    this.questions = response.data.results

                })
        }
    },

    },
})
